<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
    <link rel="stylesheet" type="text/css" href="css/login.css" ></link>
    <script src="js/jquery-1.8.0.js"></script>
    <script>
        $(function(){
            $("#btn_img").click(function(){
                if(validate()==true){
                    $.ajax({
                        url:"AdminServlet",
                        type:"post",
                        data:{adminName:adminName.value,password:password.value,flag:"login"},
                        success:function(data){
                            if(data=="2"){
                                alert("用户已锁定,不能登录,请联系管理");
                            }
                            else if(data=="0"){
                                alert("账号或密码错误,登录失败");
                            }
                            else{
                                //登录成功
                                window.location.href="main.html";
                            }
                        }
                    });
                }
            });

        });

        function validate(){
            var result=true;
            //中间进行账号和密码不能为空的校验
            if(adminName.value==""){
                result=false;
                alert("请输入账号");
            }

            if(password.value==""){
                result=false;
                alert("请输入密码");
            }
            return result;
        }
    </script>
</head>
<body>
<div id="div_center">
    <div id="div_inputbox">
        <input type="text" id="adminName" value="" />
        <input type="password" id="password" />
    </div>
    <input id="btn_img" type="image" src="images/bg_login_btn.jpg" />
</div>
</body>
</html>
